<!DOCTYPE>
<html>
  <head>
    <title>观察者模式</title>
    <script src="./index_1.js"></script>
  </head>
  <body>
  <script>
  // 来，订阅一个
  var testSubscription = pubsub.subscribe('example1', function (topics, data) {
      console.log(topics + ": " + data);
  });

  // 发布通知
  pubsub.publish('example1', 'hello world!');
  pubsub.publish('example1', ['test', 'a', 'b', 'c']);
  pubsub.publish('example1', [{ 'color': 'blue' }, { 'text': 'hello'}]);
  //退订
  setTimeout(function () {
      pubsub.unsubscribe(testSubscription);
  }, 0);
  </script
  </body>
</html>